##pip install pandas
# -*- coding: utf-8 -*-
import pandas as pd
import json
 
# 读取xlsx文件
xlsx_file = r'语言.xlsx'
df_zh = pd.read_excel(xlsx_file,engine='openpyxl',sheet_name='zh')
json_file_zh = 'zh.json'
with open(json_file_zh, 'w', encoding='utf-8') as f:
    first = True
    f.write('[\n')
    for index, row in df_zh.iterrows():
        if not first:
            f.write(',\n')
        json_data = row.to_json(orient='split', force_ascii=False)
        json.dump(json.loads(json_data.strip('"')), f, ensure_ascii=False, indent=4)
        first = False
    f.write(']\n')
print('zh ok')

df_zh = pd.read_excel(xlsx_file,engine='openpyxl',sheet_name='en')
json_file_en = 'en.json'
with open(json_file_en, 'w', encoding='utf-8') as f:
    first = True
    f.write('[\n')
    for index, row in df_zh.iterrows():
        if not first:
            f.write(',\n')
        json_data = row.to_json(orient='split', force_ascii=False)
        json.dump(json.loads(json_data.strip('"')), f, ensure_ascii=False, indent=4)
        first = False
    f.write(']\n')
print('en ok')
